package org.lzfto.flink.demo.business.flinkTest.flinkObjects.source.mqtt;

import java.io.Serializable;

import org.lzfto.flink.demo.business.flinkTest.test.TestUtil;
import org.lzfto.flink.demo.config.AppConfiguration;
import org.lzfto.flink.demo.config.MyAppProperties;

/**
 * MQTT连接配置信息
 * 
 * @author lzfto
 * @创建时间 2025年6月13日 17:38:03
 * @版本 1.0
 * @apiNote 说明：MQTT连接配置信息
 * <pre>
 *   各个属性如下：
 *   artemisHost: artemis服务器地址
 *   artemisUserName: artemis用户名
 *   artemisPassword: artemis密码
 *   topic: 订阅的topic
 *   mqttClientId: 客户端ID
 *   websocketClientName: websocket客户端名称
 *   qos: 消息质量等级，0：最多一次；1：至少一次；2：恰好一次。默认为1
 *</pre>
 */
public class MqttConnectionConfig implements Serializable {
	private static final long serialVersionUID = 1L;
	private String artemisHost;
	private String artemisUserName;
	private String artemisPassword;
	private String topic;
	private Integer qos;
	/**
	 * mqtt客户端ID
	 */
	private String mqttClientId;
	private String websocketClientName;

	public MqttConnectionConfig(AppConfiguration config, String websocketClientName, String mqttClientId,
			String mqttTopicSuffix) {
		MyAppProperties appConfig = config.getAppProp();
		this.artemisHost = config.getArtemisHost();
		this.artemisUserName = config.getArtemisUserName();
		this.artemisPassword = config.getArtemisPassword();
		this.topic = TestUtil.buildMqttTopic(appConfig.getMqttTopicPrefix(), mqttTopicSuffix);
		this.qos = config.getAppProp().getMqttQos();
		this.websocketClientName = websocketClientName;
		this.mqttClientId = mqttClientId;
	}

	public MqttConnectionConfig withClientId(String clientId) {
		this.mqttClientId = clientId;
		return this;
	}

	public MqttConnectionConfig withQos(Integer qos) {
		this.qos = qos;
		return this;
	}

	public MqttConnectionConfig withTopic(String topic) {
		this.topic = topic;
		return this;
	}

	public String getArtemisHost() {
		return artemisHost;
	}

	public String getArtemisUserName() {
		return artemisUserName;
	}

	public String getArtemisPassword() {
		return artemisPassword;
	}

	public String getTopic() {
		return topic;
	}

	public Integer getQos() {
		return qos;
	}

	public String getMqttClientId() {
		return mqttClientId;
	}

	public String getWebsocketClientName() {
		return websocketClientName;
	}

	public void setWebsocketClientName(String websocketClientName) {
		this.websocketClientName = websocketClientName;
	}

}
